package genetic.q3.functions.math;

import genetic.Function;
import genetic.TreeNode;
import genetic.q3.functions.Computable;
import genetic.q3.functions.SymbolicRegressionFunction;

public class IEEEremainder extends SymbolicRegressionFunction{

	public IEEEremainder() {
		super(null);
	}
	
	public IEEEremainder(TreeNode[] kids) {
		super(kids);
	}

	@Override
	public Function createInstance(TreeNode[] kids) {
		return new IEEEremainder(kids);
	}

	@Override
	public TreeNode createRandomInstance(TreeNode[] kids) {
		return new IEEEremainder(kids);
	}

	@Override
	public int getNumKids() {
		return 2;
	}

	@Override
	public String getName() {
		return "IEEEremainder";
	}

	@Override
	public double compute(double xVal) {
		double val1 = ((Computable)kids[0]).compute(xVal);
		double val2 = ((Computable)kids[1]).compute(xVal);
		if (val2 == 0) return val1;
		return Math.IEEEremainder(val1, val2);
	}
}
